<%@page isELIgnored="false" import="java.net.*" %>
<%@taglib prefix="tiles" uri="struts-tiles" %>
<%@taglib prefix="html" uri="struts-html" %>
<%@taglib prefix="c" uri="jstl" %>
<%@taglib prefix="fn" uri="jstl-fn" %>
					<div id="bodyContent">
						<h1>Create New User</h1>
						
						<center>
						<html:form action='CrearUsuarioCrear.do' method='post' focus="campo1">
						<html:hidden property="catalogoId" value="13"/>
						<html:hidden property="operation" value="5"/>
						<br/>
						
						<div class='errors'>
						<html:errors/>
						</div>
						
						<table class="TablaCatalogosNuevoTipoCuenta">
							<thead>
								<tr>
									<th>
										New User - Assign Levels
									</td>
								</tr>
							</thead>
							<tr>
								<td>
									<br/>
									<table class='TablaCatalogosFields'>
										<tr>
											<td class='TDLabel'>
												Login: &nbsp;&nbsp;
											</td>
											<td class='TDField'>
												${UserLogin.newUser.login}
											</td>
										</tr>
										<tr>
											<td class='TDLabel'>
												Password: &nbsp;&nbsp;
											</td>
											<td class='TDField'>
												${UserLogin.newUser.pass}
											</td>
										</tr>
										<tr>
											<td class='TDLabel'>
												Name: &nbsp;&nbsp;
											</td>
											<td class='TDField'>
												${UserLogin.newUser.name}
											</td>
										</tr>
										<tr>
											<td class='TDLabel'>
												Email: &nbsp;&nbsp;
											</td>
											<td class='TDField'>
												${UserLogin.newUser.email}
											</td>
										</tr>
                                                                                <tr>
											<td class='TDLabel'>
												Country: &nbsp;&nbsp;
											</td>
											<td class='TDField'>
												${UserLogin.newUser.pais.nombre}
											</td>
										</tr>
										<tr>
<c:set value="${UserLogin.newUser.roles}" var="Roles" />
<c:set value="${fn:length(Roles)}" var="RolesLength" />

<c:set value="${MCCatalogs.allActiveAgencies}" var="ActiveAgencies" />
<c:set value="${fn:length(ActiveAgencies)}" var="ActiveAgenciesLength" />

<c:forEach items="${Roles}" varStatus="status" var="rol">
<c:set value="${status.index}" var="StatusIndex" scope="request" />
<c:if test="${( (StatusIndex mod 2) eq 0 )}">
											<td class='TDLabel'>
</c:if>
<c:if test="${( (StatusIndex mod 2) ne 0 )}">
											<td class='TDLabel' style="text-align: left;">
</c:if>
												Role '${rol.nombre}':<br/>
<c:set value="${rol.tblNivels}" var="RoleLevels" />
<c:set value="${fn:length(RoleLevels)}" var="RoleLevelsLength" />
<c:choose>
<c:when test="${RoleLevelsLength ne 0}">
												<select name="campoIntArr1" multiple size="4">
<c:forEach items="${RoleLevels}" var="rolLevel">
													<option value="${rolLevel.cveNivel}" >${rolLevel.nombre}</option>
</c:forEach>
												</select>
</c:when>
<c:otherwise>
												No levels for this role.
</c:otherwise>
</c:choose>
											</td>
   <c:if test="${rol.cveRole eq 4 }">       
       <td class='TDLabel' style="text-align: left;">
				Agency:<br/>					<html:select property="campo6" size="${ActiveAgenciesLength}">
<c:forEach items="${ActiveAgencies}" var="agen">
													<option value="${agen.cveAgencia}">${agen.nombre}</option>
</c:forEach>
												</html:select>
										</td>
   </c:if>
<c:if test="${( (StatusIndex mod 2) ne 0 ) and ( not status.last ) }">
										</tr>
										<tr>
</c:if>
<c:if test="${( (StatusIndex mod 2) eq 0 ) and ( status.last ) }">
											<td class='TDLabel'>
												&nbsp;
											</td>
</c:if>                                                                                           
 
</c:forEach>
										</tr>
										<tr>
											<td colspan='2' class='TDButton'>
												<html:submit value='Create' styleClass="ButtonSubmit" />
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
						</html:form>
						</center>
					</div>
					<div id="footContent"></div>
